<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
	<title>用户发票管理</title>
	<link rel="stylesheet" href="/static/layui/assets/css/layui.css">
    <link rel="stylesheet" href="/static/layui/assets/css/view.css"/>
    <link rel="icon" href="/favicon.ico">
</head>
<body class="layui-view-body">
    <div class="layui-content">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-body" >
                    <div class="form-box">
                        <div class="layui-form layui-form-item">
                            <div class="layui-inline">
                                <div class="layui-form-mid">行数:</div>
                                <div class="layui-input-inline" style="width: 50px;">
                                  <input type="text" autocomplete="off" name="limit" id="pagesize" class="layui-input" onkeyup="value=value.replace(/[^\d]/g,'')" onchange="touserpower(value)" th:value="${pagesize}">
                                </div>
                                <button class="layui-btn layui-btn-blue" onclick="window.location.reload()">刷新</button>
                            </div>
                        </div>
                        <div id="">
                        	<table class="layui-table" >
							  <thead>
							    <tr style="text-align: center;">
							   	  <th style="text-align: center;">序号</th>
							      <th style="text-align: center;">发票号码</th>
							      <th style="text-align: center;">姓名</th>
							      <th style="text-align: center;">发票代码</th>
							      <th style="text-align: center;">金额</th>
							      <th style="text-align: center;">开票时间</th>
							      <th style="text-align: center;">报销时间</th>
							      <th style="text-align: center;">操作</th>
							    </tr> 
							  </thead>
							  <tbody id="tbody">
							  </tbody>
							</table>
							<div>  
								<div style="float: left;line-height:50px;">
									共<span id='totalElements'></span>条数据&emsp;
									第<span id='etNumber'>1</span>页/共<span id='totalPages'></span>页
								</div>
	                        	<div id="page"  style="text-align:right;"></div>
                        	</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/static/layui/assets/layui.js" th:inline="none" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/jquery-1.4.4.min.js"  th:inline="none"></script>
</body>
<script type="text/javascript"  th:inline="none">
var pagesize=$('#pagesize').val();
/* 分页 */
layui.use(['laypage', 'layer'], function(){
	var laypage = layui.laypage ,layer = layui.layer;
	var url='userpage';
	$.post(url,function(count){
		var pagecount = count/pagesize;
		console.log('总记录数：'+count+',总页数：'+pagecount);
		laypage.render({
			elem:'page',
			count:pagecount*10, //总共的数据
		    jump: function(obj){
		      var pageindex=obj.curr;
		      loaduserlist(pageindex);
		    }
		  });
	});
});
	/* 加载第X页数据 */
	function loaduserlist(pageindex){
		console.log('第' + pageindex + '页');
		var url="userinlist?pageindex="+pageindex+"&pagesize="+pagesize;
		$.post(url,function(user){
			var html="";
			var b=1;
			$.each(user.content,function (n,value) {
				html +='<tr  style="text-align: center;">';
				html +='	<td width="5%;">'+b+'</td>';
				html +='	<td width="13%;">'+value.number+'</td>';
				html +='	<td width="10%;">'+value.name+'</td>';
				html +='	<td width="12%;">'+value.code+'</td>';
				html +='	<td width="10%;">'+value.money+'</td>';
				html +='	<td width="15%;">'+value.mindate+'</td>';
				html +='	<td width="20%;">'+value.maxdate+'</td>';
				html +='	<td width="15%;">';
				html +='	 <button onmouseout="toremove('+b+')" onmouseover="goremove('+b+')" onclick="butremove('+value.id+','+value.number+')" id="but'+b+'" class="layui-btn layui-btn-danger layui-btn layui-btn-xs"><i class="layui-icon">&nbsp;&#xe640;</i></button>';
				html +='</td>';
				html +='</tr>';
				b=b+1;
			})
			$('#tbody').html(html);
			/* 提示 */
			$('#totalElements').html(user.totalElements);
			$('#etNumber').html(user.number+1);
			$('#totalPages').html(user.totalPages);
		},'json')
	}
	function touserpower(value){
		window.location.href="eiminvoice?pagesize="+value; 
	}
	
	function goedit(b){
		$("#butt"+b).html('<i class="layui-icon">&nbsp;&#xe642;编辑</i>')
	}
	
	function toedit(b){
		$("#butt"+b).html('<i class="layui-icon">&nbsp;&#xe642;</i>')
	}
	
	function goremove(b){
		$("#but"+b).html('<i class="layui-icon">&nbsp;&#xe640;删除</i>')
	}
	
	function toremove(b){
		$("#but"+b).html('<i class="layui-icon">&nbsp;&#xe640;</i>')
	}
	
	function butremove(value,b){
		layer.confirm("你确定删除报销号码为 "+b+" ？", {
			btn:['确定', '取消']
		}, function(){ 
			window.location.href="userremove?id="+value;
		});
	}
</script>
</html>